package com.wei.czz.common.enums.admin.user;

import com.wei.czz.common.dto.common.NameValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wyw
 * date: 2024-06-23 21:20:26
 * className: UserRiskTypeEnum
 * version: 1.0
 * description:
 */
@Getter
@AllArgsConstructor
public enum UserRiskTypeEnum {

    USER_RISK_TYPE(0, "管理员操作"), SYSTEM_RISK_TYPE(1, "系统判定"),

    ;

    /**
     * 值
     */
    private final Integer value;

    /**
     * 名称
     */
    private final String name;

    /**
     * 获取名称
     * @param value 值
     * @return 名称
     */
    public static String getName(Integer value) {
        for (UserRiskTypeEnum userRiskTypeEnum : values()) {
            if (userRiskTypeEnum.value.equals(value)) {
                return userRiskTypeEnum.name;
            }
        }
        return "";
    }

    /**
     * 获取枚举列表
     */
    public static List<NameValue<Integer>> getList() {
        return Stream.of(values())
                .map(userRiskTypeEnum -> new NameValue<>(userRiskTypeEnum.name, userRiskTypeEnum.value))
                .collect(Collectors.toList());
    }
}
